import { ToolTipItem } from "../../../../com/mui/manager/ToolTipItem";
import { SPetInfo } from "../../../../Message/Game/SPetInfo";
import { PetUtil } from "./info/PetUtil";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { TPetUpgrage } from "../../../../Message/Db/Tables/TPetUpgrage";
//class PetTileItem
    
    export  class PetTileItem extends ToolTipItem
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._spiritBitmap = new Object /* flash.display.Bitmap */();
            this.addChild(this._spiritBitmap);
            this._growthBitmap = new Object /* flash.display.Bitmap */();
            this._growthBitmap.x = 32;
            this._growthBitmap.y = -1;
            this.addChild(this._growthBitmap);
            return;
        }

        public get petInfo(): SPetInfo
        {
            return this._petInfo;
        }

        public set petInfo(arg1: SPetInfo)
        {
            this._petInfo = arg1;
            if (arg1) 
            {
                this._growthPU = PetUtil.getGrowthTitle(arg1.growth);
                this._spiritPU = PetUtil.getSpiritTitle(arg1.spirit);
                LoaderHelp.addResCallBack(ResFileConst.petInfo, this.updateBitmap);
            }
            else 
            {
                if (this._growthBitmap) 
                {
                    this._growthBitmap.bitmapData = null;
                }
                if (this._spiritBitmap) 
                {
                    this._spiritBitmap.bitmapData = null;
                }
                this.mouseEnabled = false;
            }
            return;
        }

        /* internal  */updateBitmap(): void
        {
            if (this._growthPU) 
            {
                this._growthBitmap.bitmapData = PetUtil.getTileBitmap(this._growthPU.grade, true).bitmapData;
            }
            else if (this._growthBitmap) 
            {
                this._growthBitmap.bitmapData = null;
            }
            if (this._spiritPU) 
            {
                this._spiritBitmap.bitmapData = PetUtil.getTileBitmap(this._spiritPU.grade, false).bitmapData;
            }
            else if (this._spiritBitmap) 
            {
                this._spiritBitmap.bitmapData = null;
            }
            this.toolTipData = PetUtil.getPetTitleTipData(this._petInfo.growth, this._petInfo.spirit);
            this.mouseEnabled = true;
            return;
        }

        /* internal */ /* var */_growthBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_spiritBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_petInfo: SPetInfo;

        /* internal */ /* var */_growthPU: TPetUpgrage;

        /* internal */ /* var */_spiritPU: TPetUpgrage;
    }
